<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑房间周卫生和消毒记录表</title>
	<#include "/common/resource.ftl">
    <link rel="stylesheet" href="${params.contextPath}/static/plug/layui/css/layui.css">
    <style>
        .layui-form select {display:none !important;}
    </style>
	<script type="text/javascript">
		$(function () {
            $.ajaxRequest({
                url: '${params.contextPath}/web/room/roomList',
                data: {},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var record = data.data;
                    var floorStr = "<option value=''>请选择</option>";
                    for (var i = 0; i < record.length; i++) {
                        floorStr += "<option value='" + record[i] + "'>"+ record[i] +"楼</option>";
                    }
                    $("#roomId").empty();
                    $("#floorNum").append(floorStr);
                    layui.form.render();
                }
            });
			<#if (params.id)??>
				$.ajaxRequest({
					url: '${params.contextPath}/web/roomDisinfectionRecords/query.json',
					data: {id: "${params.id}"},
					success: function (data) {
						if (!data.success) {
							$.message(data.message);
							return;
						}
						var record = data.data;
						for (var key in record) {
							$("[name='" + key + "']").val(record[key]);
						}
						// 获取floorNum
                        var floorNum = record.floorNum;
						// 获取roomNum
                        var roomNum = record.roomNum;
                        $.ajaxRequest({
                            url: '${params.contextPath}/web/room/roomList',
                            data: {floorNum: floorNum},
                            success: function (data) {
                                if (!data.success) {
                                    $.message(data.message);
                                    return;
                                }
                                var record = data.data;
                                var roomStr = "<option value=''>请选择</option>";
                                for (var i = 0; i < record.length; i++) {
                                    if (roomNum == record[i].roomNum) {
                                        roomStr += "<option value='" + record[i].id + "' selected>" + record[i].roomNum + "</option>";
                                    } else {
                                        roomStr += "<option value='" + record[i].id + "'>" + record[i].roomNum + "</option>";
                                    }
                                }
                                $("#roomId").empty();
                                $("#roomId").append(roomStr);
                                layui.form.render();
                            }
                        });
                        layui.form.render();
					}
				});
			</#if>

            $(".ajax-form").unbind().submit(function () {
                try {
                    var form = $(this);
                    if (!form.valid()) {
                        $.message("验证不通过，无法提交表单");
                        return false;
                    }

                    form.formSubmit({
                        callBack:function (data) {
                            <#if (params.tag)??>
                            history.go(-1);
                            </#if>
                        }
                    });
                } catch (e) {
                    console.log("表单提交错误：" + e);
                }
                return false;
            });
		});
	</script>
</head>
<body>
	<div class="ui-form">
		<form class="layui-form ajax-form" action="${params.contextPath}/web/roomDisinfectionRecords/<#if (params.id)??>modify<#else>save</#if>.json" method="post">
			<input type="hidden" name="id" value="${params.id}" />
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">楼层<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select lay-filter="floorNum" id="floorNum" name="floorNum" class="layui-input {required:true}">

                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">房间号<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select id="roomId" name="roomId" class="layui-input {required:true}">

                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">房间卫生状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="roomHygieneStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">房间卫生间状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="roomBathroomStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">房间地面状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="roomGroundStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">毛巾是否消毒<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="towelDisinfectionStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已消毒</option>
                                        <option value="2">未消毒</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">口杯餐具是否消毒<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="cupwareDisinfectionStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已消毒</option>
                                        <option value="2">未消毒</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">脸盆脚盆是否消毒<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="washbasinDisinfectionStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已消毒</option>
                                        <option value="2">未消毒</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">是否开窗通风<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="openWindowStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">玻璃清洁状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="glassCleanStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">床单换洗状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="bedChangeStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">抹布拖把状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="ragMopStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">卫生间消毒状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="toiletDisinfectionStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已消毒</option>
                                        <option value="2">未消毒</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">轮椅状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="wheelchairStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">走廊状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="corridorStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">护栏状态<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="guardrailStatus" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">已做</option>
                                        <option value="2">未做</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="submit" value="保存" class="layui-btn" />
				</div>
			</div>
		</form>
	</div>
</body>
<#--<script src="${params.contextPath}/static/plug/layui/layui.all.js"></script>-->
<script>

    layui.use(['element','form'], function() {
        var form = layui.form;
        form.on('select(floorNum)', function (data) {
            $.ajaxRequest({
                url: '${params.contextPath}/web/room/roomList',
                data: {floorNum: $("[name='floorNum']").val()},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var record = data.data;
                    var roomStr = "<option value=''>请选择</option>";
                    for (var i = 0; i < record.length; i++) {
                        roomStr += "<option value='" + record[i].id + "'>" + record[i].roomNum + "</option>";
                    }
                    $("#roomId").empty();
                    $("#roomId").append(roomStr);
                    layui.form.render();
                }
            });
        });
    });
</script>
</html>
